const columns = (expand, onDownloadFile, namespace, n) => {
    return [
        {
          type: 'expand',
          width: 50,
          render: (h, {row}) => {
              if(row.children.length > 0) {
                return h(expand, {
                  props: {
                      data: row.children,
                      expand,
                      onDownloadFile,
                      namespace,
                      n: n + 1
                  }
                })
              } else {
                return null
              }
          }
        },
        {
          title: '资源名称',
          key: 'fileName',
          width: 280,
          render: (h, { row, column, index }) => {
            return h('P', {
              style: {
                textIndent:n * 20 + 'px'
              }
            },[
                h('Icon', {
                    props: {
                        type: row.isDirectory === 'Y' ? 'ios-folder-outline' : 'document'
                    },
                }),
                h('span', {
                  style: {
                    marginLeft:'5px'
                  }
                }, row.fileName)
            ]);
          }
        },
        {
            title: '文件路径',
            key: 'filePath',
        },
        {
          title: '是否是目录',
          key: 'isDirectory',
          width: 100,
          render:(h, {row}) => {
            return row.isDirectory === 'Y' ? '是' : '否'
          }
        },
        {
            title: '文件时间',
            key: 'fileTime',
            width: 180
        },
        {
            title: '文件大小(KB)',
            width:180,
            key: 'fileSize'
        },
        {
            title: '操作',
            key: 'operation',
            width: 100,
            render: (h, { row, column, index }) => {
                return h('div', [
                    h('Button', {
                        on: {
                            click: () => onDownloadFile(row.filePath, row.fileName)
                        },
                        props: {
                            type: 'text',
                            size: 'small',
                            disabled:row.isDirectory === 'Y'
                        },
                    }, '下载')
                ]);
            }
        }
    ]
}
export default columns;
